package gebruikersinterface;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class Scherm extends JFrame{
	
	private Hoofdscherm hoofdscherm;
	private Rekeningenlijst rekeningenscherm;
	private DetailRekeningen detailscherm;
	private Menu menubalk;
	private JPanel wrapper;

	public Scherm(){
		super("FloorMaster");
			Dimension d = new Dimension(1024, 768);
			this.setSize(1024, 768);
			this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
			this.setMinimumSize(d);
			this.setLocationRelativeTo(null);
			this.setExtendedState(this.getExtendedState()|JFrame.MAXIMIZED_BOTH);
			this.setLayout(new BorderLayout());
			this.setVisible(true);		
		
		this.wrapper = new JPanel(new GridLayout(2,1,10,10));
			this.wrapper.setPreferredSize(new Dimension(300, 0));
			this.wrapper.setBackground(new Color(15,15,15));
		
			
		this.hoofdscherm = new Overzicht(this);		
			this.hoofdscherm.setPreferredSize(new Dimension(300, 300));
			this.hoofdscherm.setBackground(new Color(240,240,240));
			
		this.rekeningenscherm = new Rekeningenlijst(this);
			this.rekeningenscherm.setPreferredSize(new Dimension(300, 0));
			this.rekeningenscherm.setBackground(new Color(0,255,0));
		
		this.detailscherm = new DetailRekeningen(this);
			this.detailscherm.setPreferredSize(new Dimension(300, 0));
			this.detailscherm.setBackground(new Color(240,240,240));
		
		this.menubalk = new Menu(this);
			this.menubalk.setPreferredSize(new Dimension(0, 86));
			this.menubalk.setBackground(new Color(10,10,10));
				

		this.add(this.hoofdscherm, BorderLayout.CENTER);
		this.add(this.menubalk, BorderLayout.PAGE_END);
		this.add(this.wrapper, BorderLayout.LINE_END);
			this.wrapper.add(this.rekeningenscherm);
			this.wrapper.add(this.detailscherm);	
	}
	
	public void setScherm(Hoofdscherm paneel){
		this.remove(this.hoofdscherm);
		this.hoofdscherm = paneel;
		this.add(this.hoofdscherm);
		this.refresh();
	}
	
	public void sluit(){
		this.dispose();
		Aanmelden aanmelden = new Aanmelden();
	}
	
	public void refresh(){
		this.refresh(false);
	}
	
	public void refresh(boolean rekeningen){
		if(rekeningen) this.rekeningenscherm.refresh();
		this.detailscherm.refresh();
		this.hoofdscherm.refresh();
		this.menubalk.refresh();
	}
}